﻿using Digitalmes.Domain.Entities.Mes.Masters;

namespace Digitalmes.Application.Mes.Masters.Lines.Commands;

/// <summary>
/// 删除产线命令。
/// </summary>
/// <param name="LineId"></param>
public record DeleteLineCommand(long LineId) : IRequest<IResult<bool>>;

internal sealed class DeleteLineCommandHandler(IRepository<MdLine> repo) : IRequestHandler<DeleteLineCommand, IResult<bool>>
{
    public async Task<IResult<bool>> Handle(DeleteLineCommand request, CancellationToken cancellationToken)
    {
        var ok = await repo.DeleteByIdAsync(request.LineId, cancellationToken);
        return Result.From(ok);
    }
}
